package com.alex.algorithm.array;


public class AddTwoNumbers {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
        if(l1 == null && l2 == null) {
            return null;
        }
        if(l1 != null && l2 == null) {
            return l1;
        }
        if(l1 == null && l2 != null) {
            return l2;
        }
        ListNode first;
        int fistval = l1.val + l2.val;
        first = new ListNode(fistval % 10);
        first.next = addTwoNumbers(l1.next, l2.next);
        ListNode node = first.next;



        if(node == null && fistval >= 10){
            first.next = new ListNode(1);
        }
        return first;
    }
}
